package com.ce.webframework.sec.dao.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.FetchMode;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import com.ce.webframework.sec.dao.ISecDragSourceTempDao;
import com.ce.webframework.sec.model.SecDragSourceTempDO;
import com.sitechasia.webx.core.dao.hibernate3.HibernateDomainObjectDao;

public class SecDragSourceTempDaoImpl
	extends HibernateDomainObjectDao<SecDragSourceTempDO> implements ISecDragSourceTempDao {

	/**
	 * 返回指定企业中的指定用户的拖动源
	 * @param userId 用户标识
	 * @param type  类型
	 * @param epId 企业标识
	 * @param functionEntityId 功能标识
	 * @return SecDragSourceTempDO集合
	 */
	@SuppressWarnings("unchecked")
	public List<SecDragSourceTempDO> getDragSourceTemps(Long userId
			,String type, Long epId, List<String> functionEntityIds){

		Criteria crit = this.getEntityCriteria();
		crit.setFetchMode("secDragTargetDO", FetchMode.JOIN);
		crit.add(Restrictions.eq("type", type));
		crit.add(Restrictions.eq("epId", epId));
		crit.add(Restrictions.in("functionEntityId", functionEntityIds.toArray()));
		crit.addOrder(Order.asc("dragSourceTempId"));

		return crit.list();

	}

}
